package com.lenovo.spider.domain;

import com.lenovo.spider.component.TaskProcess.Downloader.Type;
import lombok.*;

import java.io.Serializable;
import java.net.Proxy;
import java.util.Map;
import java.util.Optional;

/**
 * 请求
 *
 * @author <a href="mailto:liuhan3@lenovo.com">HanL(liuhan3)</a>
 * on 2018/3/19 18:06
 */
@Data
@ToString(of = {"url", "downloaderType"})
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Request implements Serializable {
    private String url;
    private Proxy proxy;
    private Map<String, String> headers;
    private Map<String, String> cookies;
    private Map<String, Object> extra;
    private Boolean checkDuplicate;
    private Type downloaderType;
    private int priority;
    private boolean useCookie;
    private boolean changeProxy;

    public boolean isCheckDuplicate() {
        return Optional.ofNullable(checkDuplicate).orElse(true);
    }

}
